Skip to content

add: tree layout for sitemap#115

Open
dinoallo wants to merge 2 commits intoteesloane:masterfrom
dinoallo:feature/sitemap_tree_layout
Open

add: tree layout for sitemap#115
dinoallo wants to merge 2 commits intoteesloane:masterfrom
dinoallo:feature/sitemap_tree_layout

Conversation

@dinoallo
Copy link
Copy Markdown

@dinoallo dinoallo commented Aug 1, 2022

The "tree" layout for sitemap is to render the directories where
the org files reside, which may be useful for some who want their
sitemap more organized.

To use the layout, simply change sitemap.layout in config.yaml
to "tree". Any values other than that will fall back to the default layout.

Currently this layout sorts the files by their real path on the machine
rather than by their titles, so if the titles are not consistent with their
filenames, the sitemap will probably be different in that case.

This pr also uses the percent representation in sitemap urls. It fixes
the broken link issue if the filenames and dirnames have space, question
mark, etc.

- Use the percent representation in sitemap urls to avoid "naughty"
filenames and dirnames.
- The "tree" layout for sitemap is to render the directories where
the org files reside, which may be useful for some who want their
sitemap more organized.
@dinoallo
Copy link
Copy Markdown
Author

dinoallo commented Aug 1, 2022

A picture is worth a thousand words:
https://imgur.com/a/j7ysEcF

@teesloane
Copy link
Copy Markdown
Owner

Hi there!

Thanks for making a PR. This is a bit of a complex one for me, so I'm going to have to pull down the code and test it.

For some context, from a product side, In previous versions of Firn I tried enabling rendering of the sitemap as a tree-ish structure through the use of a FIRN_UNDER key in the frontmatter. This way files could be "under" another file, regardless of their file structure, and then be rendered as such. It was a pain, and I'd say doing it by file system makes a lot more sense.

I have not looked at this codebase for a few months, so I'll need to test this locally when I have a chance; It might not be until the end of this week or next week, unfortunately. Hopefully you don't mind waiting.

I have two requests:

  1. Do you mind adding a test or two, if you can think of an appropriate place for them? I'm trying to be a bit more diligent with my testing.
  2. Can you tell me how to recreate the bug you identified ("This pr also uses the percent representation in sitemap urls. It fixes the broken link issue if the filenames and dirnames have space, questionmark, etc.") so I can try to recreate it? Namely:
  • where do the links break (in the old sitemap?)
  • an example file name to test (I'm guessing anything with an empty space?)

@dinoallo
Copy link
Copy Markdown
Author

dinoallo commented Aug 2, 2022

I have not looked at this codebase for a few months, so I'll need to test this locally when I have a chance; It might not be until the end of this week or next week, unfortunately. Hopefully you don't mind waiting.

Sure! I deploy my own version of firn so it's not huge problem for me if the patch has not been merged to origin/master. For anyone who wants to get a bit of taste, you can always check out my fork for firn.

I have two requests:

  1. Do you mind adding a test or two, if you can think of an appropriate place for them? I'm trying to be a bit more diligent with my testing.

I will try to come up some tests when I am free :)

  1. Can you tell me how to recreate the bug you identified ("This pr also uses the percent representation in sitemap urls. It fixes the broken link issue if the filenames and dirnames have space, questionmark, etc.") so I can try to recreate it? Namely:
  • where do the links break (in the old sitemap?)
  • an example file name to test (I'm guessing anything with an empty space?)

Let's say I have a file structure like this:

└── Space Folder
        └── leaf3.org

On current master branch, the link will be rendered like:

<a href="http://localhost:8080/Space" folder="" leaf3.html="">Leaf 3</a>

Another example is when the org file is called: questionmark?.org, the link
will be just fine but it's not confined to the URL standard, which causes problems while serving(404).

fix issues with unusual filenames and dirnames (e.g. consisting of spaces)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants